package tk.jfree.example.gridfs.swagger;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @author Cheng.Wei
 * @date 2019/03/24 17:20
 */
@Configuration
@EnableSwagger2
public class Swagger {
    private static ApiInfo allInfo() {
        return new ApiInfoBuilder().title("mongodb-gridfs").description("mongodb-gridfs")
                .contact(new Contact("Cheng.Wei", "tencent://message/?uin=930098011", "dhweicheng@163.com"))
                .license("其他信息...")
                .licenseUrl("http://blog.csdn.net/dhweicheng").version("1.0.0").build();
    }

    @Bean
    @Lazy
    public Docket platformApi() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("all").apiInfo(allInfo())
                .forCodeGeneration(true)
                .select()
                .paths(Predicates.not(PathSelectors.ant("/error")))
                .apis(RequestHandlerSelectors.any())
                .build();


    }
}
